package demoMod.stsconsole.powers;

import demoMod.stsconsole.core.AbstractCreature;
import demoMod.stsconsole.interfaces.MonsterDeathSubscriber;
import demoMod.stsconsole.monsters.AbstractMonster;

public class MinionPower extends AbstractPower implements MonsterDeathSubscriber {
    public static final String ID = "MinionPower";
    private final AbstractCreature source;
    private boolean escape = false;

    public MinionPower(AbstractCreature owner, AbstractCreature source) {
        super(ID, owner, new int[0]);
        this.source = source;
    }

    @Override
    public String getUpdatedDescriptions() {
        return String.format(this.description, this.source.name);
    }

    @Override
    public void onMonsterDeath(AbstractMonster monster) {
        if (monster == this.source) {
            if (escape) {
                this.owner.escape();
            } else {
                this.owner.die();
            }
        }
    }

    public AbstractPower setEscape(boolean escape) {
        this.escape = escape;
        return this;
    }
}
